<?php
class Default_MailController extends Zend_Controller_Action {
	private $_model_contact;
	public function init() {
		/* Initialize action controller here */
		$this->_model_contact = new Admin_Model_DbTable_Contact ();
		$this->_helper->layout ()->disableLayout ();
	}
	public function indexAction() {
		// action body
	}
	public function contactadminAction() {
		// action body
		$success = 1;
		$name = $_POST ["name"];
		$company_name = $_POST ["company_name"];
		$email = $_POST ["email"];
		$content = $_POST ["content"];
		$mail_to = MAIL_TO;
		
		$to = $mail_to;
		$subject = MAIL_SUBJECT;
		$message = $content;
		$headers = "From: $email" . "\r\n" . "Reply-To: $mail_to" . "\r\n" . 'X-Mailer: PHP/' . phpversion ();
		
		try {
			mail ( $to, $subject, $message, $headers );
			
			date_default_timezone_set('Asian/Hanoi');
		    $date = new Zend_Date();
     		
			$success = $this->_model_contact->addContact ( NULL, $name, $company_name, NULL, $email, NULL, NULL, $date->toString("yyyy-MM-dd"), $message, 1 );
		} catch ( Exception $e ) {
			$success = $e;
		}
		echo $success;
		die();
	}
	public function contacttenantAction() {
		// action body
		$success = 1;
		$name = $_POST ["name"];
		$company_name = $_POST ["company_name"];
		$email = $_POST ["email"];
		$content = $_POST ["content"];
		$mail_to = MAIL_TO;
		
		$to = $mail_to;
		$subject = MAIL_SUBJECT;
		$message = $content;
		$headers = "From: $email" . "\r\n" . "Reply-To: $mail_to" . "\r\n" . 'X-Mailer: PHP/' . phpversion ();
		
		try {
			$success = mail ( $to, $subject, $message, $headers );
		} catch ( Exception $e ) {
			$success = $e;
		}
		echo $success;
	}
}





